/*
 * =====================================================================================
 *
 *       Filename:  contacts_redis.h
 *
 *    Description:  interface declaration for redis adapter of recent contacts.
 *
 *        Version:  1.0
 *        Created:  2013年05月15日 13时44分59秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Wu Yuxin (wyx, Hin)
 *        Company:  www.Qihoo.net
 *
 * =====================================================================================
 */

#ifndef __IMSERVER_IM_CONTACTSSERVICE_CONTACTREDIS_H__
#define __IMSERVER_IM_CONTACTSSERVICE_CONTACTREDIS_H__

#include <stdint.h>
#include "ImServiceCommon_types.h"
#include "redis_executor/redis_executor.h"

class RedisLocator;

namespace imserver {

class ContactRedis {
public:
  // Create a new ContactRedis associating it with the given RedisLocator.
  ContactRedis(RedisLocator *locator);

  // Add contact.
  // Check the sender and receiver exists, if exist, update it, otherwise insert.
  int AddContact(const int64_t sender, const int64_t receiver, const time_t timestamp);
  int RemoveContact(const int64_t sender, const int64_t receiver);
  int GetContacts(RecentContactList& contacts, const int64_t uid, const int32_t offset, const int32_t count);
  int Flag(const int64_t uid);
  int AddFavorite(const int64_t sender, const int64_t receiver);
  int RemoveFavorite(const int64_t sender, const int64_t receiver);
  int Remark(const int64_t sender, const int64_t receiver, const std::string& remark);
  int GetFavorite(RecentContactList& contacts, const int64_t uid, const int32_t offset, const int32_t count);

private:
  RedisExecutor redis_;

};

}

#endif //__IMSERVER_IM_CONTACTSSERVICE_CONTACTREDIS_H__
